<template>
  <div class="home-container" v-loading="loading">
    <div class="flex">
      <!-- 20181106版begin -->
      <!--<div class="left-container flex flex-v flex-1" v-if="tradeData" v-show="false">-->
        <!--<img src="https://www.ddmg.com/ThinkDM/data/upload/admin/20180903/5b8cd46579681.png" class="banner"/>-->
        <!--<trade-data :data="tradeData"/>-->
        <!--<trade-chart :charData="tradeData.fifteenSaleList"/>-->
      <!--</div>-->
      <!--<div class="right-container flex flex-v" v-show="false">-->
      <!--<user-info :data="userInfo" v-if="userInfo" />-->
      <!--<short-cut />-->
      <!--<div class="news-qa flex flex-v">-->
      <!--<div class="title">新闻</div>-->
      <!--<div class="flex flex-1 flex-center-vh" style="color: #adadad;">正在建设中</div>-->
      <!--</div>-->
      <!--</div>-->
      <!-- 20181106版end -->
      <div class="container-box flex">
        <div class="info">
          <user-infos :data="userInfo" v-if="userInfo"/>
        </div>
        <div class="menu-path">
          <short-cuts :pdfpath="pdfpath" :isAdmin="isAdmin"/>
        </div>
        <!--<div class="tradeDatas">-->
        <!--<trade-datas :data="tradeData"/>-->
        <!--</div>-->
      </div>
    </div>
    <div class="ddjsd" @click="showDialog" >
      <img src="https://www.ddmg.com/ThinkDM/data/upload/admin/20190124/5c497bfe31356.png" class="banner"/>
    </div>
    <ddjsd ref="ddjsd" />
  </div>
</template>

<script>
import tradeData from "./components/tradeData";
// import userInfo from "./components/userInfo";
// import tradeChart from "./components/tradeChart";
import userInfos from "./components/userInfos";
import shortCuts from "./components/shortCuts";
// import tradeDatas from "./components/tradeDatas";
// import ddjsd from "@/components/AgreementsDialog/ddjsd";

import * as HttpServices from "@/api/HttpServices";

export default {
  name: "index",
  components: {
    tradeData,
    // userInfo,
    // tradeChart,
    userInfos,
    shortCuts,
    // tradeDatas,
    ddjsd
  },
  data() {
    return {
      userInfo: null,
      tradeData: null,
      loading: false,
      signatureData: null,
      pdfpath: null,
      isAdmin: false,
    };
  },
  mounted() {
    this.getHomePersonInfo();
  },

  // beforeRouteEnter(to, from, next) {
  //   next(vm => {
  //     if (!to.params.isTabClick) {
  //       vm.getHomePersonInfo();
  //     }
  //   });
  // },

  methods: {
    //获取个人信息
    async getHomePersonInfo() {
      this.loading = true;
      const res = await HttpServices.startApiReq("U2000600");
      if (res.code === 200) {
        let { user, assessrpt } = res.data;
        this.userInfo = user;
        // this.pdfpath = assessrpt.file_osspath;
        this.pdfpath = assessrpt.file_osspath || 'http://www.imooc.com';
        this.isAdmin = user.emp_role_id == 2 ? true: false;
        this.$store.dispatch("d2admin/user/set", {
          name: this.userInfo.company_name
            ? this.userInfo.company_name
            : this.userInfo.name
        });
        this.loading = false;
        // this.getTradeInfo();
      }
    },
    //获取交易数据信息
    async getTradeInfo() {
      const res = await HttpServices.startCerpApiReq("E3000100");
      if (res.code === 200) {
        res.data &&
          res.data.fifteenSaleList.map(item => {
            item.sale_amount = item.sale_amount * 1;
            item.sale_weight = item.sale_weight * 1;
            return item;
          });
        this.tradeData = res.data;
        this.loading = false;
      }
    },

    showDialog() {
      this.$refs.ddjsd.closeDialog();
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.home-container {
  background-color: #f2f2f2;
  height: 100vh;
  padding: 4px;
  overflow-y: auto;
  .left-container {
    .banner {
      width: 100%;
      margin-bottom: 4px;
    }
  }
  .right-container {
    width: 320px;
    .news-qa {
      background-color: white;
      margin: 0 4px;
      flex: 1;
      .title {
        height: 33px;
        line-height: 33px;
        padding-top: 3px;
        padding-left: 8px;
        border-bottom: 1px solid #f2f2f2;
      }
    }
  }
  /*20181106版end*/
  .container-box {
    align-content: flex-start;
    flex-wrap: wrap;
    width: 100%;
    margin: 20px 35px;
    .info {
      height: 400px;
      flex: 0 0 350px;
      margin-right: 35px;
    }
    .menu-path {
      height: 400px;
      overflow: hidden;
      flex: 1;
    }
    .tradeDatas {
      margin-top: 20px;
      flex: 0 0 100%;
    }
  }

  .ddjsd {
    cursor: pointer;
    padding: 10px;
    margin-left: 20px;
  }
}
</style>
